package com.kuaimacode.kframework.mp;

import com.alibaba.fastjson.JSONObject;
import com.google.gson.Gson;
import com.google.gson.GsonBuilder;


public class JsonUtils {
    public static String toJson(Object obj) {
        Gson gson = new GsonBuilder()
            .setPrettyPrinting()
            .create();
        return gson.toJson(obj);
    }

    public static <T> T parseJson(String json, Class<T> clazz) {
        return JSONObject.parseObject(json, clazz);
    }

    public static JSONObject parseJson(String json) {
        return JSONObject.parseObject(json);
    }
}
